home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Override a cpp macro?
- Date: 10 Jan 1996 20:11:59 GMT
- Organization: Los Alamos National Laboratory
- Distribution: world
- Message-ID: <TANMOY.96Jan10131159@qcd.lanl.gov>
- References: <4d0v5r$6fs@oak78.doc.ic.ac.uk>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: rwmj@doc.ic.ac.uk's message of 10 Jan 1996 18:05:47 -0000
-
- --text follows this line--
- In article <4d0v5r$6fs@oak78.doc.ic.ac.uk> rwmj@doc.ic.ac.uk (Richard
- Jones) writes:
-
- I'm trying to redefine a cpp macro, but using the old definition. I've got
- a macro defined:
-
- #define m1(a,b) /* some hidden definition of m1 */
-
- and in another file, I want to redefine m1 in terms of the old (unknown)
- definition. Two obvious ways would be:
-
- #define old_m1(a,b) m1(a,b)
- #undef m1
- #define m1(a,b) (old_m1(a,b)+1)
-
- or:
-
- #define new_m1(a,b) (m1(a,b)+1)
- #undef m1
- #define m1(a,b) new_m1(a,b)
-
- But neither works as expected. I've tried variations using the macro:
-
- I am sorry. There is no way in standard C to do it. Your compile may
- (or more probably will not) provide an extension.
-
- #define expand(a) a
-
- which according to the Gnu info page for (Gnu) cpp should expand the
- argument first. However, no known combination works.
-
- It does expand a `first', but `first' at the time when expand(a) is
- used, not when it is defined.
-
- What's the way to do this? Surely this is an obvious thing to want to do,
- so there must be some simple point I'm missing?
-
- Unfortunately, the C preprocessor has very limited capabilities. No,
- it is not an obvious thing to want to do in a C preprocessor.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-